#include "Precompiled.hpp"


Entity::Entity()
{}

Entity::~Entity()
{}

void Entity::AddComponent(TypelessHandle& newComponent)
{
  components.push_back(newComponent);
}

void Entity::RemoveComponent(TypelessHandle& target)
{
  for (unsigned int index = 0; index < components.size(); ++index)
  {
    if(components[index] == target)
    {
      target.Delete();
      components.erase(components.begin() +index);
      break;
    }
  }
}

void Entity::BindEntities()
{
  ASSERT(self.IsValid());
  for (unsigned int index = 0; index < components.size(); ++index)
  {

  }
}

TypelessHandle Entity::GetComponent(const std::type_info& componentType)
{
  for(unsigned int index = 0; index < components.size(); ++index)
  {
    if(componentType == typeid(*(reinterpret_cast<ComponentInterface*>(components[index].GetData()))))
    {
      return components[index];
    }
  }
  return TypelessHandle();
}

Handle<Entity> Entity::GetSelf()
{
  return self;
}

void Entity::SetSelf(const Handle<Entity>& newSelf)
{
  self = newSelf;
}